package com.iwhalecloud.bss.kite.cucc.service.attr.linkhandler;

import com.iwhalecloud.bss.kite.client.enums.TriggerStrategy;
import com.iwhalecloud.bss.kite.cucc.common.constant.LocalKeyConsts;
import com.iwhalecloud.bss.kite.cucc.service.attr.handler.DamageFeeRuleAttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.annotation.AttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.impl.AbstractAttrLinkageHandler;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import org.springframework.stereotype.Service;

import java.util.Objects;

@Service
@AttrHandler(DamageFeeRuleAttrHandler.class)
public class DamageFeeRuleAttrLinkHandler extends AbstractAttrLinkageHandler<AttrData> {
    @Override
    public void handle(KiteAttr attr, KiteInst inst, AttrData data) {

    }

    @Override
    public void handleStyle(KiteAttr attr, KiteInst inst, AttrData data) {
        //是否收取违约金
        KiteAttr damageFeeSwitchAttr = inst.getAttr("210004554");
        //违约金金额
        KiteAttr DamageFeeAttr = inst.getAttr("210004556");
        if (Objects.isNull(DamageFeeAttr)) {
            return;
        }
        if ("1_0000106".equals(damageFeeSwitchAttr.getValue()) && "110007675".equals(attr.getValue())) {
            DamageFeeAttr.setIsNull(LocalKeyConsts.IFTRUE_F);
            DamageFeeAttr.setShowType(LocalKeyConsts.PROD_ATTR_SHOW_TYPE_D);
        }
        else {
            DamageFeeAttr.setIsNull(LocalKeyConsts.IFTRUE_T);
            DamageFeeAttr.setShowType(LocalKeyConsts.PROD_ATTR_SHOW_TYPE_E);
        }
        if (TriggerStrategy.LOAD_VALUE.equals(data.getTriggerStrategy()) && "110007676".equals(attr.getValue())) {
            damageFeeSwitchAttr.setIsNull(LocalKeyConsts.IFTRUE_F);
            damageFeeSwitchAttr.setShowType(LocalKeyConsts.PROD_ATTR_SHOW_TYPE_D);
        }
    }
}
